package com.translate.web.api.controller;

import javax.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.NativeWebRequest;

import com.param.impl.IdPageParam;
import com.translate.vo.CommissionManagementDetailVO;
import com.response.vo.ResponseModel;
import com.controller.base.AbstractCommonController;
import com.translate.web.param.CommissionManagementDetailUpdateParam;
import com.translate.web.param.UserIdParam;
import com.translate.web.param.CommissionManagementDetailAddParam;
import com.translate.entity.CommissionManagementDetail;
import com.translate.web.service.ICommissionManagementDetailService;
import com.basic.service.contract.IBaseService;

@RestController
@RequestMapping("commissionManagementDetail")
public class CommissionManagementDetailController
		extends AbstractCommonController<CommissionManagementDetail, UserIdParam> {
	private ICommissionManagementDetailService service;

	public CommissionManagementDetailController(ICommissionManagementDetailService service) {
		this.service = service;
	}
	
	@Override
	protected void frontProcesserVO(UserIdParam param, NativeWebRequest object) {
		// TODO Auto-generated method stub
		param.setUserId((int) this.getUserId(object));
		super.frontProcesserVO(param, object);
	}

	/**
	 * 添加
	 * 
	 * @param <V>
	 * @param param
	 * @return
	 */
	@PostMapping("/add")
	public ResponseModel<Integer> insert(@RequestBody @Validated CommissionManagementDetailAddParam param,
			HttpServletRequest httpServletRequest) {
		int id = this.service.parseInsert(param, CommissionManagementDetail.class);

		return ResponseModel.<Integer>success(id);
	}

	@Override
	protected IBaseService<CommissionManagementDetail> getBaseService() {
		return this.service;
	}

	
	
	/**
	 * 添加
	 * 
	 * @param <V>
	 * @param param
	 * @return
	 */
	@PostMapping("/update")
	public ResponseModel<Integer> update(@Validated @RequestBody CommissionManagementDetailUpdateParam param,
			HttpServletRequest httpServletRequest) {
		int res = this.service.parseUpdate(param, CommissionManagementDetail.class);
		return ResponseModel.<Integer>success(res);
	}

	protected <VO> Class<VO> getTarget() {
		return (Class<VO>) CommissionManagementDetailVO.class;
	}
}